package cn.itcast.exam.dao.impl;

import cn.itcast.exam.dao.UserDao;
import cn.itcast.exam.pojo.User;
import cn.itcast.exam.utils.jdbctemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class UserDaoimpl implements UserDao {
   private JdbcTemplate jdbcTemplate=jdbctemplate.getjdbctemplate();

    @Override
    public Integer loginDao(User user) {
String sql="SELECT * FROM tab_user WHERE username= ? AND password= ?";
        List<User> users = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(User.class), user.getUserName(), user.getPassword());
        return users.size();
    }
}
